package com.etime.shycourse.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.config.PageMessage;
import com.etime.shycourse.dto.OrgTeacherDtoS;
import com.etime.shycourse.services.interfaces.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : TeacherController  //类名
 * @Description :  教师管理 //描述
 * @Author : W //作者
 * @Date: 2022/4/6  10:36
 */
@Api(tags = "后台-教师管理-数据接口")
@RestController
@RequestMapping("/sys/teacher")
public class TeacherController {
    @Autowired
    private TeacherService service;

    @ApiOperation("教师分页查询列表  可使用用户名查找")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "usertruename", value = "可选择条件姓名"),
            @ApiImplicitParam(name = "tecorgid", value = "教师所属机构"),
            @ApiImplicitParam(name = "pageNum", value = "第几页"),
            @ApiImplicitParam(name = "pageSize", value = "每页多少行"),
    })
    @GetMapping("/page")
    public PageMessage<OrgTeacherDtoS> selectTeacherPage(OrgTeacherDtoS dto, Long pageNum, Long pageSize) {
        PageMessage<OrgTeacherDtoS> msg = new PageMessage<> ();
        Page<OrgTeacherDtoS> orgTeacherDtoPage = service.selectTeacherPage (dto, pageNum, pageSize);
        if (orgTeacherDtoPage != null) {
            msg.setCode (1);
            msg.setPagedata (orgTeacherDtoPage);
        } else {
            msg.setCode (0);
            msg.setMsg ("没有查询到数据");
        }
        return msg;
    }
}

